LF-5211: Farm notes data model and API#4091
Draft
litefarm-pr-bot wants to merge 5 commits intointegrationfrom
Draft
LF-5211: Farm notes data model and API#4091litefarm-pr-bot wants to merge 5 commits intointegrationfrom
litefarm-pr-bot wants to merge 5 commits intointegrationfrom
Conversation
Adds the full backend for the farm notes feature: three Knex migrations (farm_note table, farm_notes_read table, permissions), two Objection models, two controllers with CRUD + read-status handlers, two Express routes, server mounts, hasFarmAccess entity getter, and integration tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
kathyavini
reviewed
Mar 18, 2026
| }; | ||
| }, | ||
|
|
||
| editFarmNote() { |
Collaborator
There was a problem hiding this comment.
@SayakaOno I saw this in the RTK Query endpoint too, but I have no idea why the file / image is excluded from the PATCH; I don't think that was part of the plan (or maybe I missed it!)
I'm double-checking with Loïc here, but I'm pretty sure anything that can be set in POST (including image) should be PATCH-able.
Collaborator
There was a problem hiding this comment.
For image removal on the PATCH, I am planning to send data.image_url = null. Let me know if that works for you 🙏
Collaborator
There was a problem hiding this comment.
It should work, thank you!
Collaborator
There was a problem hiding this comment.
Just FYI, I've updated the patch request body and pushed!
* use middlware in post/patch routes * add/adjust tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
LiteFarm has no first-class way for farm members to leave notes visible to the whole team on the Home dashboard. This PR adds the backend data model and REST API for the Farm Notes / Noticeboard feature, providing the foundation that frontend PRs will build on.
Two new tables are introduced:
farm_note(per-farm notes with optional image attachment and anis_privateflag so authors can keep notes to themselves) andfarm_notes_read(a composite-PK table recording each user's last-read timestamp, enabling the unread indicator badge). Four CRUD permissions are seeded (IDs 188–191,get/add/edit/delete:farm_notes) and assigned to all active roles.Controllers enforce authorship:
PATCHandDELETErequireuser_idto match the note's author, returning 403 otherwise.GETfilters results so private notes are only returned to their author. Image uploads are compressed viaimaginaryPostand stored in S3. All new routes go through the standardcheckScope+hasFarmAccessmiddleware chain;farm_note_idis registered inentitiesGettersso cross-farm access is blocked by the existing ACL infrastructure.Jira link: https://lite-farm.atlassian.net/browse/LF-5211
Type of change
How Has This Been Tested?
20 integration tests added covering all four CRUD endpoints plus the read-tracking endpoints:
farmNote.test.js(14 tests): GET visibility rules (public/private/wrong-farm), POST with and without file, PATCH author/non-author/wrong-farm, DELETE soft-delete/non-author/wrong-farmfarmNotesRead.test.js(6 tests): GET returns null before any mark-read, returns timestamp after, wrong-farm 403; PATCH creates row, updates timestamp, wrong-farm 403Integration tests run against a real test DB with the new migrations applied. No frontend component in this PR — visual review not applicable. CI will run the full test suite.
Checklist:
pnpm i18nto help with this)